package cn.ytian.scashier;

import java.io.Serializable;
import java.util.Objects;

public class Product implements Serializable {
    private String goodsID;
    private String goodsName;
    private double goodsPrice;



    public String getGoodsID() {
        return goodsID;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public double getGoodsPrice() {
        return goodsPrice;
    }

    public void setGoodsID(String goodsID) {
        this.goodsID = goodsID;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public void setGoodsPrice(double goodsPrice) {
        this.goodsPrice = goodsPrice;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Product)) return false;
        Product rainmeter = (Product) o;
        return getGoodsID() == rainmeter.getGoodsID() && Double.compare(rainmeter.getGoodsPrice(), getGoodsPrice()) == 0 && Objects.equals(getGoodsName(), rainmeter.getGoodsName());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getGoodsID(), getGoodsName(), getGoodsPrice());
    }

    public Product(String goodsID, String goodsName, double goodsPrice) {
        this.goodsID = goodsID;
        this.goodsName = goodsName;
        this.goodsPrice = goodsPrice;
    }

    public Product(String goodsID, String goodsName, String goodsPrice) {
        this.goodsID = goodsID;
        this.goodsName = goodsName;
        this.goodsPrice = Double.parseDouble(goodsPrice);
    }

    public Product() {
    }

    @Override
    public String toString() {
        return "Product{" +
                "goodsID=" + goodsID +
                ", goodsName='" + goodsName + '\'' +
                ", goodsPrice=" + goodsPrice +
                '}';
    }

    public String toPln() {
        return "\t" + goodsID +
                "\t\t" + goodsName +
                "\t\t" + goodsPrice;
    }
}
